For the color quantization problem of color images, the K-means clustering algorithm has strong dependence on initial conditions and is easy to fall into local optimum, and the traditional intelligent optimization algorithms only consider the mutual competition between individuals in the population layer and ignores the mutual cooperation between the population layers. To solve the problems, a K-means-based PES (Pyramid Evolution Strategy) color image quantization algorithm was proposed. Firstly, the clustering loss function in K-means clustering algorithm was used as the fitness function of the new algorithm; secondly, PES was used for the population initialization, layering, exploration, acceleration and clustering of the colors; finally, the new algorithm was used to quantify four standard color test images at different color quantization levels. The experimental results show that the proposed algorithm can improve the defects of the K-means clustering algorithm and the traditional intelligent algorithm. Under the criterion of intra-class mean squared error, the average distortion rate of the image quantized by the new algorithm is 12.25% lower than that quantized by the PES-based algorithm, 15.52% lower than that quantized by the differential evolution algorithm, 58.33% lower than that quantized by the Particle Swarm Optimization (PSO) algorithm, 15.06% lower than that quantized by the K-means algorithm; and the less the color quantization levels, the more the image distortion rate reduced quantized by the new algorithm than that quantized by other algorithms. In addition, the visual effect of the image quantized by the proposed algorithm is better than that quantized by other algorithms.